﻿using EXT;
using System;
using System.Linq;
using System.Data;
using BanHangCshap.Class;
using System.Windows.Forms;
using System.Collections.Generic;
using DevExpress.Utils;

namespace BanHangCshap.BaoCaoTongHop
{
    public partial class frmThongkeXuatNhapTon : Form
    {
        public frmThongkeXuatNhapTon()
        {
            InitializeComponent();
        }

        PhieuNhapXuat clspnx = new PhieuNhapXuat();

        //public void loadDSKho()
        //{
        //    Kho clskho = new Kho();
        //    DataTable dt = clskho.layDSKho();
        //    DataRow dr = dt.NewRow();
        //    dr[0] = "";
        //    dr[1] = "";
        //    dr[2] = "";
        //    dt.Rows.InsertAt(dr, 0);
        //    glkuKho.Properties.DataSource = dt;
        //    glkuKho.Properties.ValueMember = "makho";
        //    glkuKho.Properties.DisplayMember = "tenkho";
        //}

        private void frmThongkeXuatNhapTon_Load(object sender, EventArgs e)
        {
            dtpTungay.EditValue = DateTime.Now;
            dtpDenngay.EditValue = DateTime.Now;
            //loadDSKho();
        }

        private void btnXem_Click(object sender, EventArgs e)
        {
            WaitDialogForm dg = new WaitDialogForm("Đang load dữ liệu...", "Xin chờ trong giây lát.");
            DataTable dt = new DataTable();
            string makho = "";

            if (makho == "")
            {
                dt = clspnx.PhieuNhapXuat_ThongkeXuatNhapTon(false, dtpTungay.EditValue, dtpDenngay.EditValue, makho);
            }
            else
                dt = clspnx.PhieuNhapXuat_ThongkeXuatNhapTon(true, dtpTungay.EditValue.ToDateTime().ToShortDateString().ToDateTime(), dtpDenngay.EditValue.ToDateTime().ToShortDateString().ToDateTime(), makho);

            if (dt != null)
            {
                if (dt.Rows.Count >= 0)
                {
                    gcMain.DataSource = dt;
                }
                else gcMain.DataSource = null;
                bandedGridView1.BestFitColumns();
            }
            else gcMain.DataSource = null;

            if (radCachhienthi.SelectedIndex.ToInt32()==0)
            {
                v1.Visible = true;
                v2.Visible = true;
                //v3.Visible = true;
                v4.Visible = true;
                v5.Visible = true;
                //v6.Visible = true;
                v7.Visible = true;
                v8.Visible = true;
                c1.Visible = false;
                c2.Visible = false;
                c3.Visible = false;
                c4.Visible = false;
                c5.Visible = false;
                //c6.Visible = false;
                //c7.Visible = false;
                c8.Visible = false;
            }
            else if (radCachhienthi.SelectedIndex.ToInt32() == 1)
            {
                v1.Visible = false;
                v2.Visible = false;
                //v3.Visible = false;
                v4.Visible = false;
                v5.Visible = false;
                //v6.Visible = false;
                v7.Visible = false;
                v8.Visible = false;
                c1.Visible = true;
                c2.Visible = true;
                c3.Visible = true;
                c4.Visible = true;
                c5.Visible = true;
                //c6.Visible = true;
                //c7.Visible = true;
                c8.Visible = true;
            }
            else
            {
                v1.Visible = true;
                v2.Visible = true;
                //v3.Visible = true;
                v4.Visible = true;
                v5.Visible = true;
                //v6.Visible = true;
                v7.Visible = true;
                v8.Visible = true;
                c1.Visible = true;
                c2.Visible = true;
                c3.Visible = true;
                c4.Visible = true;
                c5.Visible = true;
                //c6.Visible = true;
                //c7.Visible = true;
                c8.Visible = true;
            }

            dg.Close();
        }

        private void bandedGridView1_MouseWheel(object sender, MouseEventArgs e)
        {
           // bandedGridView1.GridMouseWheel(e);
        }
    }
}
